home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / mod_cp.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  39.3 KB  |  1,459 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Moderation Control Panel module
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 19th February 2002
  19. |
  20. |   > Module Version 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Moderate;
  26.  
  27. class Moderate {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.  
  33.     var $moderator = array();
  34.     var $forum     = array();
  35.     var $topic     = array();
  36.     
  37.     var $upload_dir = "";
  38.  
  39.     
  40.     /***********************************************************************************/
  41.     //
  42.     // Our constructor, load words, load skin, print the topic listing
  43.     //
  44.     /***********************************************************************************/
  45.     
  46.     function Moderate() {
  47.     
  48.         global $ibforums, $DB, $std, $print, $skin_universal;
  49.         
  50.         // Make sure this is a POST request, not a naughty IMG redirect
  51.         
  52.         require "./Skin/".$ibforums->skin_id."/skin_mod.php";
  53.         
  54.         //-------------------------------------
  55.         // Compile the language file
  56.         //-------------------------------------
  57.         
  58.         $ibforums->lang  = $std->load_words($ibforums->lang, 'lang_mod'  , $ibforums->lang_id);
  59.         $ibforums->lang  = $std->load_words($ibforums->lang, 'lang_topic', $ibforums->lang_id);
  60.  
  61.         $this->html      = new skin_mod();
  62.         
  63.         //-------------------------------------
  64.         // Check the input
  65.         //-------------------------------------
  66.         
  67.         
  68.         
  69.         $ibforums->input['f'] = $std->is_number($ibforums->input['f']);
  70.         if (! $ibforums->input['f'] )
  71.         {
  72.             $std->Error( array( 'LEVEL' => 1,'MSG' => 'missing_files') );
  73.         }
  74.         
  75.         $ibforums->input['st'] = $ibforums->input['st'] ? $std->is_number($ibforums->input['st']) : 0;
  76.         
  77.         
  78.         //-------------------------------------
  79.         // Get the forum info based on the forum ID, get the category name, ID, and get the topic details
  80.         //-------------------------------------
  81.         
  82.         $DB->query("SELECT f.*, c.name as cat_name, c.id as cat_id from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input['f']." and c.id=f.category");
  83.         
  84.         $this->forum = $DB->fetch_row();
  85.         
  86.         
  87.         //-------------------------------------
  88.         // Error out if we can not find the forum
  89.         //-------------------------------------
  90.         
  91.         if (!$this->forum['id'])
  92.         {
  93.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  94.         }
  95.         
  96.         $pass = 0;
  97.         
  98.         $this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  99.         
  100.         if ($ibforums->member['id'])
  101.         {
  102.             if ($ibforums->member['g_is_supmod'] == 1)
  103.             {
  104.                 $pass = 1;
  105.             }
  106.             else
  107.             {
  108.                 $DB->query("SELECT * FROM ibf_moderators WHERE forum_id='".$this->forum['id']."' AND member_id='".$ibforums->member['id']."'");
  109.                 if ( $this->moderator = $DB->fetch_row() )
  110.                 {
  111.                     $pass = 1;
  112.                 }
  113.             }
  114.         }
  115.         
  116.         if ($pass == 0)
  117.         {
  118.             $std->Error( array( LEVEL => 1, MSG => 'no_permission') );
  119.         }
  120.         
  121.         $this->upload_dir = $ibforums->vars['upload_dir'];
  122.         
  123.         $this->upload_dir = preg_replace( "!/$!", "", $this->upload_dir );
  124.         
  125.         //-------------------------------------
  126.         
  127.         $print->add_output( $this->html->Menu_bar($this->base_url, $this->forum['id']) );
  128.         
  129.         //-------------------------------------
  130.         // Convert the code ID's into something
  131.         // use mere mortals can understand....
  132.         //-------------------------------------
  133.         
  134.         switch ($ibforums->input['CODE']) {
  135.         
  136.             case 'edituser':
  137.                 $this->find_user_one();
  138.                 break;
  139.             case 'dofinduser':
  140.                 $this->find_user_two();
  141.                 break;
  142.             case 'doedituser':
  143.                 $this->edit_user();
  144.                 break;
  145.             case 'compedit':
  146.                 $this->complete_user_edit();
  147.                 break;
  148.             
  149.             //-------------------------
  150.             
  151.             case 'prune':
  152.                 $this->prune_juice();
  153.                 break;
  154.             case 'doprune':
  155.                 $this->drink_prune_juice();  // eew!
  156.                 break;
  157.             case 'domove':
  158.                 $this->do_move();
  159.                 break;
  160.                 
  161.             //-------------------------
  162.             
  163.             case 'modtopics':
  164.                 $this->mod_topics();
  165.                 break;
  166.             case 'domodtopics':
  167.                 $this->domod_topics();
  168.                 break;
  169.                 
  170.             case 'modposts':
  171.                 $this->mod_posts();
  172.                 break;
  173.             case 'modtopicview':
  174.                 $this->mod_topicview();
  175.                 break;
  176.                 
  177.             case 'domodposts':
  178.                 $this->mod_domodposts();
  179.                 break;
  180.                 
  181.             case 'modtopicapprove':
  182.                 $this->approve_all();
  183.                 break;
  184.             
  185.             default:
  186.                 $this->splash();
  187.                 break;
  188.         }
  189.         
  190.         // If we have any HTML to print, do so...
  191.         
  192.         $fj = $std->build_forum_jump();
  193.         $fj = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $fj);
  194.         
  195.         $this->output .= $this->html->CP_end();
  196.         
  197.         $this->output .= $this->html->forum_jump($fj, $links);
  198.         
  199.         if ( count($this->nav) < 1 )
  200.         {
  201.             $this->nav[] = "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>";
  202.             $this->nav[] = "<a href='{$this->base_url}&act=ModCP&f={$this->forum['id']}'>{$ibforums->lang['cp_modcp_home']}</a>";
  203.         }
  204.         
  205.         if (! $this->page_title )
  206.         {
  207.             $this->page_title = $ibforums->lang['cp_modcp_ptitle'];
  208.         }
  209.         
  210.         $print->add_output("$this->output");
  211.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 1, NAV => $this->nav ) );
  212.       
  213.     }
  214.     
  215.     
  216.     //-------------------------------------------------
  217.     // MODERATE NEW POSTS AND STUFF
  218.     //--------------------------------------------------
  219.     
  220.     function approve_all()
  221.     {
  222.         global $std, $ibforums, $DB, $print;
  223.         
  224.         
  225.         // Sort out the approved bit
  226.         
  227.         $DB->query("UPDATE ibf_posts SET queued=0 WHERE topic_id='".$ibforums->input['tid']."'");
  228.         
  229.         $DB->query("SELECT COUNT(pid) as posts FROM ibf_posts WHERE new_topic <> 1 and topic_id='".$ibforums->input['tid']."'");
  230.         $count = $DB->fetch_row();
  231.         
  232.         $DB->query("UPDATE ibf_topics SET posts=".$count['posts']." WHERE tid='".$ibforums->input['tid']."'");
  233.         
  234.         // Update the posters ..er.. post count.
  235.             
  236.         $DB->query("SELECT starter_id FROM ibf_topics WHERE tid='".$ibforums->input['tid']."'");
  237.         
  238.         $mems = array();
  239.         
  240.         while ( $r = $DB->fetch_row() )
  241.         {
  242.             if ($r['starter_id'] > 0)
  243.             {
  244.                 $mems[] = $r['starter_id'];
  245.             }
  246.         }
  247.         
  248.         if ( count($mems) > 0 )
  249.         {
  250.             $mstring = implode( ",", $mems );
  251.             
  252.             $DB->query("UPDATE ibf_members SET posts=posts+1 WHERE id IN ($mstring)");
  253.         }
  254.         
  255.         // Update the last topic poster, time and number of posts.
  256.             
  257.         $DB->query("SELECT author_id, author_name, post_date FROM ibf_posts WHERE topic_id='".$ibforums->input['tid']."' AND queued <> 1 ORDER BY pid DESC LIMIT 0,1");
  258.         
  259.         if ($last = $DB->fetch_row())
  260.         {
  261.             $db_string = $DB->compile_db_update_string( array (
  262.                                                                  'last_post'        => $last['post_date'],
  263.                                                                  'last_poster_id'   => $last['author_id'],
  264.                                                                  'last_poster_name' => $last['author_name'],
  265.                                                       )       );
  266.                                                       
  267.             $DB->query("UPDATE ibf_topics SET $db_string WHERE tid='".$ibforums->input['tid']."'");
  268.         }
  269.         
  270.         // recount...
  271.         
  272.         $this->recount();
  273.         
  274.         
  275.         // Boink
  276.         
  277.         $print->redirect_screen( $ibforums->lang['cp_redirect_mod_topics'], "act=ModCP&CODE=modposts&f=".$this->forum['id'] );
  278.         
  279.     }
  280.     
  281.     //--------------------------------------------------
  282.     
  283.     function mod_domodposts()
  284.     {
  285.         global $std, $ibforums, $DB, $print;
  286.         
  287.         //--------------------------------------------------
  288.         // Which TID's are we playing with?
  289.         //--------------------------------------------------
  290.         
  291.         $ids = array();
  292.         
  293.         foreach ($ibforums->input as $key => $value)
  294.          {
  295.              if ( preg_match( "/^PID_(\d+)$/", $key, $match ) )
  296.              {
  297.                  if ($ibforums->input[$match[0]])
  298.                  {
  299.                      $ids[] = $match[1];
  300.                  }
  301.              }
  302.          }
  303.          
  304.          //--------------------------------------------------
  305.         // Did we actually select anyfink?
  306.         //--------------------------------------------------
  307.         
  308.         if ( count($ids) < 1 )
  309.         {
  310.             $this->mod_error('cp_error_no_topics');
  311.             return;
  312.         }
  313.         
  314.         $pid_count = count($ids);
  315.         
  316.         $pids = implode( ",", $ids );
  317.         
  318.         //--------------------------------------------------
  319.         // What did we do?
  320.         //--------------------------------------------------
  321.         
  322.         if ($ibforums->input['type'] == 'approve')
  323.         {
  324.             // Sort out the approved bit
  325.             
  326.             $DB->query("UPDATE ibf_topics SET posts=posts+$pid_count WHERE tid='".$ibforums->input['tid']."'");
  327.             
  328.             $DB->query("UPDATE ibf_posts SET queued=0 WHERE pid IN ($pids)");
  329.             
  330.             // Update the posters ..er.. post count.
  331.             
  332.             $DB->query("SELECT author_id FROM ibf_posts WHERE queued <> 1 and pid IN ($pids)");
  333.             
  334.             $mems = array();
  335.             
  336.             while ( $r = $DB->fetch_row() )
  337.             {
  338.                 if ($r['author_id'] > 0)
  339.                 {
  340.                     $mems[] = $r['author_id'];
  341.                 }
  342.             }
  343.             
  344.             if ( count($mems) > 0 )
  345.             {
  346.                 $mstring = implode( ",", $mems );
  347.                 
  348.                 $DB->query("UPDATE ibf_members SET posts=posts+1 WHERE id IN ($mstring)");
  349.             }
  350.             
  351.             // Update the last topic poster, time and number of posts.
  352.             
  353.             $DB->query("SELECT author_id, author_name, post_date FROM ibf_posts WHERE topic_id='".$ibforums->input['tid']."' AND queued <> 1 ORDER BY pid DESC LIMIT 0,1");
  354.             
  355.             if ($last = $DB->fetch_row())
  356.             {
  357.                 $db_string = $DB->compile_db_update_string( array (
  358.                                                                      'last_post'        => $last['post_date'],
  359.                                                                      'last_poster_id'   => $last['author_id'],
  360.                                                                      'last_poster_name' => $last['author_name'],
  361.                                                           )       );
  362.                                                           
  363.                 $DB->query("UPDATE ibf_topics SET $db_string WHERE tid='".$ibforums->input['tid']."'");
  364.             }
  365.             
  366.             
  367.             
  368.             // recount...
  369.             
  370.             $this->recount();
  371.         }
  372.         else
  373.         {
  374.             // Delete 'dem postings
  375.             
  376.             $DB->query("DELETE FROM ibf_posts WHERE pid IN ($pids)");
  377.             
  378.             // Recount..
  379.             
  380.             $this->recount();
  381.         }
  382.         
  383.         // Boink
  384.         
  385.         $print->redirect_screen( $ibforums->lang['cp_redirect_mod_topics'], "act=ModCP&CODE=modposts&f=".$this->forum['id'] );
  386.  
  387.     }
  388.     
  389.     //**-------------------------------------------------------
  390.     
  391.     function mod_topicview()
  392.     {
  393.         global $std, $ibforums, $DB, $print;
  394.         
  395.         $DB->query("SELECT tid, title FROM ibf_topics WHERE tid='".$ibforums->input['tid']."'");
  396.         
  397.         if ( ! $DB->get_num_rows() )
  398.         {
  399.             $this->mod_error('cp_error_no_topics');
  400.             return;
  401.         }
  402.         
  403.         $topic = $DB->fetch_row();
  404.         
  405.         $this->output .= $this->html->modtopicview_start($ibforums->input['tid'], $this->forum['name'], $this->forum['id'], $topic['title']);
  406.         
  407.         
  408.         //+----------------------------------------------------------------
  409.         // Get the topics to work on
  410.         //+----------------------------------------------------------------
  411.         
  412.         $DB->query( "SELECT p.*, ".
  413.                     "m.id,m.name,m.mgroup,m.email,m.joined,m.avatar,m.avatar_size,m.posts as member_posts,m.aim_name,m.icq_number,m.signature, m.website,m.yahoo,m.title,m.hide_email,m.msnname, ".
  414.                     "g.g_id, g.g_title, g.g_icon, t.* ".
  415.                     "FROM ibf_posts p, ibf_members m, ibf_groups g, ibf_topics t ".
  416.                     "WHERE t.tid='".$ibforums->input['tid']."' AND t.approved=1 AND p.topic_id=t.tid AND p.queued=1 AND p.author_id=m.id AND g.g_id=m.mgroup ".
  417.                     "ORDER BY p.pid ASC");
  418.         
  419.         while( $r = $DB->fetch_row() )
  420.         {
  421.             $member = $this->parse_member($r);
  422.             
  423.             $r['post_date'] = $std->get_date( $r['post_date'], 'LONG' );
  424.             
  425.             $this->output .= $this->html->mod_postentry_checkbox($r['pid']);
  426.             $this->output .= $this->html->mod_postentry( array( 'msg' => $r, 'member' => $member ) );
  427.             
  428.         }
  429.         $this->output .= $this->html->mod_topic_spacer();
  430.         $this->output .= $this->html->modtopics_end();
  431.         
  432.     }
  433.     
  434.     //+----------------------------------------------------------------
  435.     //+----------------------------------------------------------------
  436.     
  437.     function mod_posts()
  438.     {
  439.         global $std, $ibforums, $DB, $print;
  440.         
  441.         
  442.         $DB->query("SELECT t.*, COUNT(p.pid) as reply_count FROM ibf_topics t, ibf_posts p WHERE p.queued=1 AND p.new_topic <> 1 AND t.tid=p.topic_id AND t.forum_id='".$this->forum['id']."' GROUP BY t.tid ORDER BY p.post_date ASC");
  443.         
  444.         if ( ! $DB->get_num_rows() )
  445.         {
  446.             $this->mod_error('cp_error_no_topics');
  447.             return;
  448.         }
  449.         
  450.         $this->output .= $this->html->modpost_topicstart($this->forum['name'], $this->forum['id']);
  451.         
  452.         //+----------------------------------------------------------------
  453.         // Get the topics to work on
  454.         //+----------------------------------------------------------------
  455.         
  456.         while( $r = $DB->fetch_row() )
  457.         {
  458.             $this->output .= $this->html->modpost_topicentry($r['title'], $r['tid'], $r['reply_count'], $this->forum['id']);
  459.         }
  460.         
  461.         $this->output .= $this->html->modpost_topicend();
  462.         
  463.     }
  464.     
  465.     //--------------------------------------------------
  466.     // MODERATE NEW TOPICS AND STUFF
  467.     //--------------------------------------------------
  468.     
  469.     function domod_topics()
  470.     {
  471.         global $std, $ibforums, $DB, $print;
  472.         
  473.         //--------------------------------------------------
  474.         // Which TID's are we playing with?
  475.         //--------------------------------------------------
  476.         
  477.         $ids = array();
  478.         
  479.         foreach ($ibforums->input as $key => $value)
  480.          {
  481.              if ( preg_match( "/^TID_(\d+)$/", $key, $match ) )
  482.              {
  483.                  if ($ibforums->input[$match[0]])
  484.                  {
  485.                      $ids[] = $match[1];
  486.                  }
  487.              }
  488.          }
  489.          
  490.          //--------------------------------------------------
  491.         // Did we actually select anyfink?
  492.         //--------------------------------------------------
  493.         
  494.         if ( count($ids) < 1 )
  495.         {
  496.             $this->mod_error('cp_error_no_topics');
  497.             return;
  498.         }
  499.         
  500.         $tids = implode( ",", $ids );
  501.         
  502.         //--------------------------------------------------
  503.         // What did we do?
  504.         //--------------------------------------------------
  505.         
  506.         if ($ibforums->input['type'] == 'approve')
  507.         {
  508.             // Sort out the approved bit
  509.             
  510.             $DB->query("UPDATE ibf_topics SET approved=1 WHERE tid IN ($tids)");
  511.             
  512.             $DB->query("UPDATE ibf_posts SET queued=0 WHERE topic_id IN ($tids)");
  513.             
  514.             // Update the posters ..er.. post count.
  515.             
  516.             $DB->query("SELECT starter_id FROM ibf_topics WHERE tid IN ($tids)");
  517.             
  518.             $mems = array();
  519.             
  520.             while ( $r = $DB->fetch_row() )
  521.             {
  522.                 if ($r['starter_id'] > 0)
  523.                 {
  524.                     $mems[] = $r['starter_id'];
  525.                 }
  526.             }
  527.             
  528.             if ( count($mems) > 0 )
  529.             {
  530.                 $mstring = implode( ",", $mems );
  531.                 
  532.                 $DB->query("UPDATE ibf_members SET posts=posts+1 WHERE id IN ($mstring)");
  533.             }
  534.             
  535.             
  536.             
  537.             
  538.             // recount...
  539.             
  540.             $this->recount();
  541.         }
  542.         else
  543.         {
  544.             // Delete 'dem postings
  545.             
  546.             $DB->query("DELETE FROM ibf_topics WHERE tid IN ($tids)");
  547.             
  548.             $DB->query("DELETE FROM ibf_posts WHERE topic_id IN ($tids)");
  549.             
  550.             // Recount..
  551.             
  552.             $this->recount();
  553.         }
  554.         
  555.         // Boink
  556.         
  557.         $print->redirect_screen( $ibforums->lang['cp_redirect_mod_topics'], "act=ModCP&CODE=modtopics&f=".$this->forum['id'] );
  558.         
  559.     }
  560.     
  561.     //**-------------------------------------------------------
  562.     
  563.     function mod_topics()
  564.     {
  565.         global $std, $ibforums, $DB, $print;
  566.         
  567.         $perpage = 10;
  568.         
  569.         $start   = $ibforums->input['st'] ? $ibforums->input['st'] : 0;
  570.         
  571.         //--------------------------------------------------
  572.         // How many topics must a man write down, before he is considered a man?
  573.         //--------------------------------------------------
  574.         
  575.         $DB->query("SELECT COUNT(tid) as tcount FROM ibf_topics WHERE approved=0 and forum_id='".$this->forum['id']."'");
  576.         $count = $DB->fetch_row();
  577.         
  578.         if ($count['tcount'] < 1)
  579.         {
  580.             $this->mod_error('cp_error_no_topics');
  581.             return;
  582.         }
  583.         
  584.         //+----------------------------------------------------------------
  585.         // Generate the forum page span links
  586.         //+----------------------------------------------------------------
  587.         
  588.         $pages = $std->build_pagelinks( array( 'TOTAL_POSS'  => $count['tcount'],
  589.                                                'PER_PAGE'    => $perpage,
  590.                                                'CUR_ST_VAL'  => $start,
  591.                                                'L_SINGLE'    => "",
  592.                                                'L_MULTI'     => $ibforums->lang['cp_pages'],
  593.                                                'BASE_URL'    => $this->base_url."&act=ModCP&CODE=modtopics&f=".$this->forum['id'],
  594.                                       )      );
  595.                                       
  596.         $this->output .= $this->html->modtopics_start($pages, $this->forum['name'], $this->forum['id']);
  597.         
  598.         //+----------------------------------------------------------------
  599.         // Get the topics to work on
  600.         //+----------------------------------------------------------------
  601.         
  602.         $DB->query( "SELECT p.*, ".
  603.                     "m.id,m.name,m.mgroup,m.email,m.joined,m.avatar,m.avatar_size,m.posts as member_posts,m.aim_name,m.icq_number,m.signature, m.website,m.yahoo,m.title,m.hide_email,m.msnname, ".
  604.                     "g.g_id, g.g_title, g.g_icon, t.* ".
  605.                     "FROM ibf_posts p, ibf_members m, ibf_groups g, ibf_topics t ".
  606.                     "WHERE t.forum_id='".$this->forum['id']."' and t.approved=0 AND p.topic_id=t.tid AND p.new_topic=1 AND p.author_id=m.id AND g.g_id=m.mgroup ".
  607.                     "ORDER BY t.tid ASC LIMIT $start, $perpage");
  608.         
  609.         while( $r = $DB->fetch_row() )
  610.         {
  611.             $member = $this->parse_member($r);
  612.             
  613.             $r['post_date'] = $std->get_date( $r['post_date'], 'LONG' );
  614.             
  615.             $this->output .= $this->html->mod_topic_title($r['title'], $r['tid']);
  616.             $this->output .= $this->html->mod_postentry( array( 'msg' => $r, 'member' => $member ) );
  617.             $this->output .= $this->html->mod_topic_spacer();
  618.         }
  619.         
  620.         $this->output .= $this->html->modtopics_end();
  621.         
  622.     }
  623.     
  624.     //--------------------------------------------------
  625.     // Do Pruney wooney
  626.     //--------------------------------------------------
  627.     
  628.     function drink_prune_juice()
  629.     {
  630.         global $std, $ibforums, $DB, $print;
  631.         
  632.         $pass = 0;
  633.         
  634.         if ($ibforums->member['g_is_supmod'] == 1)
  635.         {
  636.             $pass = 1;
  637.         }
  638.         else if ($this->moderator['mass_prune'] == 1)
  639.         {
  640.             $pass = 1;
  641.         }
  642.         else
  643.         {
  644.             $pass = 0;
  645.         }
  646.         
  647.         if ($pass == 0)
  648.         {
  649.             $this->mod_error('cp_no_perms');
  650.             return;
  651.         }
  652.         
  653.         //-----------------------------------------------
  654.         
  655.         $db_query = "SELECT tid FROM ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'";
  656.         
  657.         if ($ibforums->input['dateline'])
  658.         {
  659.             $db_query .= " AND last_post < {$ibforums->input['dateline']}";
  660.         }
  661.         
  662.         if ($ibforums->input['starter'])
  663.         {
  664.             $db_query .= " AND starter_id='".$ibforums->input['starter']."'";
  665.             
  666.         }
  667.         
  668.         if ($ibforums->input['posts'])
  669.         {
  670.             $db_query .= " AND posts < '".$ibforums->input['posts']."'";
  671.         }
  672.         
  673.         if ($ibforums->input['state'] != 'all')
  674.         {
  675.             if ($ibforums->input['state'])
  676.             {
  677.                 $db_query .= " AND state='".$ibforums->input['state']."'";
  678.             }
  679.         }
  680.         
  681.         $batch = $DB->query($db_query);
  682.         
  683.         if ( ! $num_rows = $DB->get_num_rows() )
  684.         {
  685.             $this->mod_error('cp_error_no_topics');
  686.             return;
  687.         }
  688.         
  689.         //-----------------------------------------------
  690.         // Right... to stop a potentially huge mySQL query
  691.         // from forming with IN ( ), lets do this in batches
  692.         // of 50...
  693.         //-----------------------------------------------
  694.         
  695.         $tid_array = array();
  696.         /*
  697.         if ($num_rows > 50)
  698.         {
  699.             while ( $tid = $DB->fetch_row($batch) )
  700.             {
  701.                 if ( count($tid_array) >= 50 )
  702.                 {
  703.                     $this->prune_batch( implode(",", $tid_array ) );
  704.                     $tid_array = array();
  705.                 }
  706.                 else
  707.                 {
  708.                     $tid_array[] = $tid['tid'];
  709.                 }
  710.             }
  711.         }
  712.         else
  713.         {
  714.         */
  715.             while ( $tid = $DB->fetch_row() )
  716.             {
  717.                 $tid_array[] = $tid['tid'];
  718.             }
  719.             
  720.             $this->prune_batch( implode(",", $tid_array ) );
  721.         //}
  722.         
  723.         // Recount the forum...
  724.         
  725.         $this->recount();
  726.         
  727.         $this->moderate_log("Pruned Forum");
  728.         
  729.         // Show results..
  730.         
  731.         $this->output .= $this->html->results( $ibforums->lang['cp_result_del'].$num_rows );
  732.         
  733.     }
  734.     
  735.     //--------------------------------------------------------------------------
  736.     
  737.     function prune_batch($tid_string)
  738.     {
  739.         global $std, $ibforums, $DB;
  740.         
  741.         // Check for attachments
  742.         
  743.         $DB->query("SELECT attach_id FROM ibf_posts WHERE topic_id IN ($tid_string)");
  744.         
  745.         while ( $attach = $DB->fetch_row() )
  746.         {
  747.             if ( is_file( $this->upload_dir."/".$attach['attach_id'] ) )
  748.             {
  749.                 @unlink( $this->upload_dir."/".$attach['attach_id'] );
  750.             }
  751.         }
  752.         
  753.         // Remove polls
  754.         
  755.         $DB->query("DELETE FROM ibf_polls WHERE tid IN ($tid_string)");
  756.         
  757.         // Remove poll voters
  758.         
  759.         $DB->query("DELETE FROM ibf_voters WHERE tid IN ($tid_string)");
  760.         
  761.         // Remove the topics
  762.         
  763.         $DB->query("DELETE FROM ibf_topics WHERE tid IN ($tid_string)");
  764.         
  765.         // Remove the posts
  766.         
  767.         $DB->query("DELETE FROM ibf_posts WHERE topic_id IN ($tid_string)");
  768.         
  769.     }
  770.     
  771.     
  772.     //--------------------------------------------------
  773.     // Prune Forum start
  774.     //--------------------------------------------------
  775.     
  776.     function prune_juice()
  777.     {
  778.         global $std, $ibforums, $DB, $print;
  779.         
  780.         $pass = 0;
  781.         
  782.         if ($ibforums->member['g_is_supmod'] == 1)
  783.         {
  784.             $pass = 1;
  785.         }
  786.         else if ($this->moderator['mass_prune'] == 1)
  787.         {
  788.             $pass = 1;
  789.         }
  790.         else
  791.         {
  792.             $pass = 0;
  793.         }
  794.         
  795.         if ($pass == 0)
  796.         {
  797.             $this->mod_error('cp_no_perms');
  798.             return;
  799.         }
  800.         
  801.         //-----------------------------------------------
  802.         
  803.         if ($ibforums->input['check'] == 1)
  804.         {
  805.         
  806.             $link = "";
  807.             $link_text = $ibforums->lang['cp_prune_dorem'];
  808.             
  809.             $DB->query("SELECT COUNT(tid) as tcount FROM ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'");
  810.             $tcount = $DB->fetch_row();
  811.             
  812.             $db_query = "SELECT COUNT(*) as count FROM ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'";
  813.             
  814.             if ($ibforums->input['dateline'])
  815.             {
  816.                 $date     = time() - $ibforums->input['dateline']*60*60*24;
  817.                 $db_query .= " AND last_post < $date";
  818.                 
  819.                 $link .= "&dateline=$date";
  820.             }
  821.             
  822.             if ($ibforums->input['member'])
  823.             {
  824.                 $DB->query("SELECT id FROM ibf_members WHERE name='".$ibforums->input['member']."'");
  825.                 
  826.                 if (! $mem = $DB->fetch_row() )
  827.                 {
  828.                     $this->mod_error('cp_error_no_mem');
  829.                     return;
  830.                 }
  831.                 else
  832.                 {
  833.                     $db_query .= " AND starter_id='".$mem['id']."'";
  834.                     $link     .= "&starter={$mem['id']}";
  835.                 }
  836.             }
  837.             
  838.             if ($ibforums->input['posts'])
  839.             {
  840.                 $db_query .= " AND posts < '".$ibforums->input['posts']."'";
  841.                 $link     .= "&posts={$ibforums->input['posts']}";
  842.             }
  843.             
  844.             if ($ibforums->input['topic_type'] != 'all')
  845.             {
  846.                 $db_query .= " AND state='".$ibforums->input['topic_type']."'";
  847.                 $link     .= "&state={$ibforums->input['topic_type']}";
  848.             }
  849.             
  850.             $DB->query($db_query);
  851.             $count = $DB->fetch_row();
  852.             
  853.             if ($ibforums->input['df'] == 'prune')
  854.             {
  855.                 $link = "&act=ModCP&f={$this->forum['id']}&CODE=doprune&".$link;
  856.             }
  857.             else
  858.             {
  859.                 if ($ibforums->input['df'] == $this->forum['id'])
  860.                 {
  861.                     $this->mod_error('cp_same_forum');
  862.                     return;
  863.                 }
  864.                 else if ($ibforums->input['df'] == -1)
  865.                 {
  866.                     $this->mod_error('cp_no_forum');
  867.                     return;
  868.                 }
  869.                 
  870.                 $link = "&act=ModCP&f={$this->forum['id']}&CODE=domove&df=".$ibforums->input['df'].$link;
  871.                 $link_text = $ibforums->lang['cp_prune_domove'];
  872.             }
  873.             
  874.             $confirm_html = $this->html->prune_confirm( $tcount['tcount'], $count['count'], $link, $link_text );
  875.             
  876.         }
  877.         
  878.         
  879.         $select = "<select name='topic_type' class='forminput'>";
  880.         
  881.         foreach( array( 'open', 'closed', 'link', 'all' ) as $type )
  882.         {
  883.             if ($ibforums->input['topic_type'] == $type)
  884.             {
  885.                 $selected = ' selected';
  886.             }
  887.             else
  888.             {
  889.                 $selected = '';
  890.             }
  891.             
  892.             $select .= "<option value='$type'".$selected.">".$ibforums->lang['cp_pday_'.$type]."</option>";
  893.         }
  894.         
  895.         $select .= "</select>\n";
  896.         
  897.         $forums = "<option value='prune'>{$ibforums->lang['cp_ac_prune']}</option>";
  898.         
  899.         $forums .= $std->build_forum_jump(0);
  900.         
  901.         
  902.         if ($ibforums->input['df'])
  903.         {
  904.             $forums = preg_replace( "/<option value=\"".$ibforums->input['df']."\"/", "<option value=\"".$ibforums->input['df']."\" selected", $forums );
  905.         }
  906.         
  907.         $this->output .= $this->html->prune_splash($this->forum, $forums, $select, $button, $confirm);
  908.         
  909.         if ($confirm_html)
  910.         {
  911.             $this->output = preg_replace( "/<!-- IBF\.CONFIRM -->/", "$confirm_html", $this->output );
  912.         }
  913.         
  914.     }
  915.     
  916.     
  917.     
  918.     //--------------------------------------------------
  919.     // Find a user to edit, dude.
  920.     //--------------------------------------------------
  921.     
  922.     function find_user_one()
  923.     {
  924.         global $std, $ibforums, $DB, $print;
  925.         
  926.         $pass = 0;
  927.         
  928.         if ($ibforums->member['g_is_supmod'] == 1)
  929.         {
  930.             $pass = 1;
  931.         }
  932.         else if ($this->moderator['edit_user'] == 1)
  933.         {
  934.             $pass = 1;
  935.         }
  936.         else
  937.         {
  938.             $pass = 0;
  939.         }
  940.         
  941.         if ($pass == 0)
  942.         {
  943.             $this->mod_error('cp_no_perms');
  944.             return;
  945.         }
  946.         
  947.         $this->output .= $this->html->find_user();
  948.     }
  949.     
  950.     function find_user_two()
  951.     {
  952.         global $std, $ibforums, $DB, $print;
  953.         
  954.         if ($ibforums->input['name'] == "")
  955.         {
  956.             $this->mod_error('cp_no_matches');
  957.             return;
  958.         }
  959.         
  960.         //---------------------------------
  961.         // Query the DB for possible matches
  962.         //---------------------------------
  963.         
  964.         $DB->query("SELECT id, name FROM ibf_members WHERE name LIKE '".$ibforums->input['name']."%' LIMIT 0,100");
  965.         
  966.         if ( $DB->get_num_rows() )
  967.         {
  968.             $select = "<select name='memberid' class='forminput'>";
  969.             
  970.             while ( $member = $DB->fetch_row() )
  971.             {
  972.                 $select .= "\n<option value='".$member['id']."'>".$member['name']."</option>";
  973.             }
  974.             
  975.             $select .= "</select>";
  976.             
  977.             $this->output .= $this->html->find_two($select);
  978.         }
  979.         else
  980.         {
  981.             $this->mod_error('cp_no_matches');
  982.             return;
  983.         }
  984.     }
  985.     
  986.     function edit_user()
  987.     {
  988.         global $std, $ibforums, $DB, $print, $root_path;
  989.         
  990.         $pass = 0;
  991.         
  992.         if ($ibforums->member['g_is_supmod'] == 1)
  993.         {
  994.             $pass = 1;
  995.         }
  996.         else if ($this->moderator['edit_user'] == 1)
  997.         {
  998.             $pass = 1;
  999.         }
  1000.         else
  1001.         {
  1002.             $pass = 0;
  1003.         }
  1004.         
  1005.         if ($pass == 0)
  1006.         {
  1007.             $this->mod_error('cp_no_perms');
  1008.             return;
  1009.         }
  1010.         
  1011.         if ($ibforums->input['memberid'] == "")
  1012.         {
  1013.             $this->mod_error('cp_no_matches');
  1014.             return;
  1015.         }
  1016.         
  1017.         //--------------------------------------------------
  1018.         
  1019.         $DB->query("SELECT m.*, g.* FROM ibf_members m, ibf_groups g WHERE m.id='".$ibforums->input['memberid']."' AND m.mgroup=g.g_id");
  1020.         
  1021.         if (! $member = $DB->fetch_row() )
  1022.         {
  1023.             $this->mod_error('cp_no_matches');
  1024.             return;
  1025.         }
  1026.         
  1027.         //--------------------------------------------------
  1028.         // No editing of admins!
  1029.         //--------------------------------------------------
  1030.         
  1031.         if ($ibforums->member['g_access_cp'] != 1)
  1032.         {
  1033.             if ($member['g_access_cp'] == 1)
  1034.             {
  1035.                 $this->mod_error('cp_admin_user');
  1036.                 return;
  1037.             }
  1038.         }
  1039.         
  1040.         require $root_path."sources/lib/post_parser.php";
  1041.         
  1042.         $parser = new post_parser();
  1043.         
  1044.         $editable['signature'] = $parser->unconvert($member['signature']);
  1045.         $editable['location']  = $member['location'];
  1046.         $editable['interests'] = $member['interests'];
  1047.         $editable['website']   = $member['website'];
  1048.         $editable['id']        = $member['id'];
  1049.         $editable['name']      = $member['name'];
  1050.         
  1051.         $this->output .= $this->html->edit_user_form($editable);
  1052.     }
  1053.     
  1054.     //--------------------------------------------------
  1055.     
  1056.     function complete_user_edit()
  1057.     {
  1058.         global $std, $ibforums, $DB, $print, $root_path;
  1059.         
  1060.         $pass = 0;
  1061.         
  1062.         if ($ibforums->member['g_is_supmod'] == 1)
  1063.         {
  1064.             $pass = 1;
  1065.         }
  1066.         else if ($this->moderator['edit_user'] == 1)
  1067.         {
  1068.             $pass = 1;
  1069.         }
  1070.         else
  1071.         {
  1072.             $pass = 0;
  1073.         }
  1074.         
  1075.         if ($pass == 0)
  1076.         {
  1077.             $this->mod_error('cp_no_perms');
  1078.             return;
  1079.         }
  1080.         
  1081.         if ($ibforums->input['memberid'] == "")
  1082.         {
  1083.             $this->mod_error('cp_no_matches');
  1084.             return;
  1085.         }
  1086.         
  1087.         //--------------------------------------------------
  1088.         
  1089.         $DB->query("SELECT m.*, g.* FROM ibf_members m, ibf_groups g WHERE m.id='".$ibforums->input['memberid']."' AND m.mgroup=g.g_id");
  1090.         
  1091.         if (! $member = $DB->fetch_row() )
  1092.         {
  1093.             $this->mod_error('cp_no_matches');
  1094.             return;
  1095.         }
  1096.         
  1097.         //--------------------------------------------------
  1098.         // No editing of admins!
  1099.         //--------------------------------------------------
  1100.         
  1101.         if ($ibforums->member['g_access_cp'] != 1)
  1102.         {
  1103.             if ($member['g_access_cp'] == 1)
  1104.             {
  1105.                 $this->mod_error('cp_admin_user');
  1106.                 return;
  1107.             }
  1108.         }
  1109.         
  1110.         require $root_path."sources/lib/post_parser.php";
  1111.         
  1112.         $parser = new post_parser();
  1113.         
  1114.         $ibforums->input['signature'] = $parser->convert(  array( 'TEXT'      => $ibforums->input['signature'],
  1115.                                                                   'SMILIES'   => 0,
  1116.                                                                   'CODE'      => $ibforums->vars['sig_allow_ibc'],
  1117.                                                                   'HTML'      => 0,
  1118.                                                                   'SIGNATURE' => 1
  1119.                                                         )       );
  1120.                                        
  1121.         if ($parser->error != "")
  1122.         {
  1123.             $std->Error( array( 'LEVEL' => 1, 'MSG' => $parser->error) );
  1124.         }
  1125.         
  1126.         
  1127.         $profile = array (
  1128.                            'signature'   => $ibforums->input['signature'],
  1129.                            'location'    => $ibforums->input['location'],
  1130.                            'interests'   => $ibforums->input['interests'],
  1131.                            'website'     => $ibforums->input['website']
  1132.                          );
  1133.         
  1134.         
  1135.         if ($ibforums->input['avatar'] == 1)
  1136.         {
  1137.             $profile['avatar']      = "";
  1138.             $profile['avatar_size'] = "";
  1139.         }
  1140.         
  1141.         $db_string = $DB->compile_db_update_string($profile);
  1142.         
  1143.         $DB->query("UPDATE ibf_members SET $db_string WHERE id='".$ibforums->input['memberid']."'");
  1144.         
  1145.         $this->moderate_log("Edited Profile for: {$member['name']}");
  1146.         
  1147.         $std->boink_it($ibforums->base_url."&act=ModCP&f={$ibforums->input['f']}&CODE=doedituser&memberid={$ibforums->input['memberid']}");
  1148.         exit();
  1149.     }
  1150.  
  1151.     
  1152.     //--------------------------------------------------
  1153.     // Show default ModCP screen
  1154.     //--------------------------------------------------
  1155.     
  1156.     function splash()
  1157.     {
  1158.         global $std, $ibforums, $DB, $print;
  1159.         
  1160.         // Get the counts for pending topics and posts and other assorted stuff etc and ok.
  1161.         
  1162.         $DB->query("SELECT COUNT(tid) as count FROM ibf_topics WHERE approved <> 1 and forum_id='".$this->forum['id']."'");
  1163.         $row = $DB->fetch_row();
  1164.         
  1165.         $tcount = $row['count'] ? $row['count'] : 0;
  1166.         
  1167.         //-------------------------------
  1168.         
  1169.         $DB->query("SELECT COUNT(pid) as pcount FROM ibf_posts WHERE queued=1 and new_topic <> 1 and forum_id='".$this->forum['id']."'");
  1170.         $row = $DB->fetch_row();
  1171.         
  1172.         $pcount = $row['pcount'] ? $row['pcount'] : 0;
  1173.         
  1174.         //-------------------------------
  1175.     
  1176.         $this->output .= $this->html->splash($tcount, $pcount, $this->forum['name']);
  1177.     }
  1178.     
  1179.     
  1180.     
  1181.  
  1182.     
  1183.     /*************************************************/
  1184.     
  1185.     function do_move() {
  1186.         global $std, $ibforums, $DB, $print;
  1187.         
  1188.         $pass = 0;
  1189.         
  1190.         if ($ibforums->member['g_is_supmod'] == 1)
  1191.         {
  1192.             $pass = 1;
  1193.         }
  1194.         else if ($this->moderator['mass_prune'] == 1)
  1195.         {
  1196.             $pass = 1;
  1197.         }
  1198.         else
  1199.         {
  1200.             $pass = 0;
  1201.         }
  1202.         
  1203.         if ($pass == 0)
  1204.         {
  1205.             $this->mod_error('cp_no_perms');
  1206.             return;
  1207.         }
  1208.         
  1209.         //-----------------------------------------------
  1210.         
  1211.         $db_query = "SELECT tid FROM ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'";
  1212.         
  1213.         if ($ibforums->input['dateline'])
  1214.         {
  1215.             $db_query .= " AND last_post < {$ibforums->input['dateline']}";
  1216.         }
  1217.         
  1218.         if ($ibforums->input['starter'])
  1219.         {
  1220.             $db_query .= " AND starter_id='".$ibforums->input['starter']."'";
  1221.             
  1222.         }
  1223.         
  1224.         if ($ibforums->input['posts'])
  1225.         {
  1226.             $db_query .= " AND posts < '".$ibforums->input['posts']."'";
  1227.         }
  1228.         
  1229.         if ($ibforums->input['state'] != 'all')
  1230.         {
  1231.             if ($ibforums->input['state'])
  1232.             {
  1233.                 $db_query .= " AND state='".$ibforums->input['state']."'";
  1234.             }
  1235.         }
  1236.         
  1237.         $DB->query($db_query);
  1238.         
  1239.         if ( ! $num_rows = $DB->get_num_rows() )
  1240.         {
  1241.             $this->mod_error('cp_error_no_topics'); 
  1242.             return;
  1243.         }
  1244.         
  1245.         $tid_array = array();
  1246.         
  1247.         while ($row = $DB->fetch_row())
  1248.         {
  1249.             $tid_array[] = $row['tid'];
  1250.         }
  1251.         
  1252.         //----------------------------------
  1253.         
  1254.         $tid    = implode( ",", $tid_array );
  1255.         $source = $this->forum['id'];
  1256.         $moveto = $ibforums->input['df'];
  1257.         
  1258.         //-----------------------------------
  1259.         // Check for an attempt to move into a subwrap forum
  1260.         //-----------------------------------
  1261.         
  1262.         $DB->query("SELECT subwrap, id FROM ibf_forums WHERE id='$moveto'");
  1263.         
  1264.         $f = $DB->fetch_row();
  1265.         
  1266.         if ($f['subwrap'] == 1)
  1267.         {
  1268.             $this->mod_error('cp_error_no_subforum');
  1269.             return;
  1270.         }
  1271.         
  1272.         
  1273.         //----------------------------------
  1274.         // Update the topic
  1275.         //----------------------------------
  1276.         
  1277.         $DB->query("UPDATE ibf_topics SET forum_id='$moveto' WHERE forum_id='$source' AND tid IN($tid)");
  1278.         
  1279.         //----------------------------------
  1280.         // Update the posts
  1281.         //----------------------------------
  1282.         
  1283.         $DB->query("UPDATE ibf_posts SET forum_id='$moveto' WHERE forum_id='$source' AND topic_id IN($tid)");
  1284.         
  1285.         //----------------------------------
  1286.         // Update the polls
  1287.         //----------------------------------
  1288.         
  1289.         $DB->query("UPDATE ibf_polls SET forum_id='$moveto' WHERE forum_id='$source' AND tid IN($tid)");
  1290.         
  1291.         $this->moderate_log("Mass moved topics");
  1292.         
  1293.         // Resync the forums..
  1294.         
  1295.         $this->recount($source);
  1296.         
  1297.         $this->recount($moveto);
  1298.     
  1299.         // Show results..
  1300.         
  1301.         $this->output .= $this->html->results( $ibforums->lang['cp_result_move'].$num_rows );
  1302.         
  1303.     }
  1304.     
  1305.     
  1306.     
  1307.  
  1308.     
  1309. //+---------------------------------------------------------------------------------------------
  1310.     
  1311.     
  1312.     /*************************************************/
  1313.     // MODERATE LOG:
  1314.     // ---------------
  1315.     //
  1316.     // Function for adding the mod action to the DB
  1317.     //
  1318.     /*************************************************/
  1319.     
  1320.     function moderate_log($title = 'unknown') {
  1321.         global $std, $ibforums, $DB, $HTTP_REFERER, $QUERY_STRING;
  1322.         
  1323.         $db_string = $std->compile_db_string( array (
  1324.                                                         'forum_id'    => $ibforums->input['f'],
  1325.                                                         'topic_id'    => $ibforums->input['t'],
  1326.                                                         'post_id'     => $ibforums->input['p'],
  1327.                                                         'member_id'   => $ibforums->member['id'],
  1328.                                                         'member_name' => $ibforums->member['name'],
  1329.                                                         'ip_address'  => $ibforums->input['IP_ADDRESS'],
  1330.                                                         'http_referer'=> $HTTP_REFERER,
  1331.                                                         'ctime'       => time(),
  1332.                                                         'topic_title' => "<i>Via Moderators CP</i>",
  1333.                                                         'action'      => $title,
  1334.                                                         'query_string'=> $QUERY_STRING,
  1335.                                                     )
  1336.                                             );
  1337.         
  1338.         $DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
  1339.         
  1340.     }
  1341.     
  1342.     
  1343.     /*************************************************/
  1344.     // Re Count topics for the forums:
  1345.     // ---------------
  1346.     //
  1347.     // Handles simple moderation functions, saves on
  1348.     // writing the same code over and over.
  1349.     // ASS_U_ME's that the requesting user has been
  1350.     // authenticated by this stage.
  1351.     //
  1352.     /*************************************************/
  1353.     
  1354.     function recount($fid="") {
  1355.         global $ibforums, $root_path, $DB, $std;
  1356.         
  1357.         if ($fid != "")
  1358.         {
  1359.             $this->forum['id'] = $fid;
  1360.         }
  1361.         
  1362.         $DB->query("SELECT COUNT(tid) as tcount from ibf_topics WHERE approved=1");
  1363.         $topics = $DB->fetch_row();
  1364.         
  1365.         $DB->query("SELECT COUNT(pid) as pcount from ibf_posts WHERE queued <> 1");
  1366.         $posts  = $DB->fetch_row();
  1367.         
  1368.         $DB->query("SELECT COUNT(tid) as tcount from ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."'");
  1369.         $f_topics = $DB->fetch_row();
  1370.         $f_topics['tcount'] = $f_topics['tcount'] < 1 ? 0 : $f_topics['tcount'];
  1371.         
  1372.         $DB->query("SELECT COUNT(pid) as pcount from ibf_posts WHERE queued=0 and forum_id='".$this->forum['id']."'");
  1373.         $f_posts  = $DB->fetch_row();
  1374.         $f_posts['pcount'] = $f_posts['pcount'] < 1 ? 0 : $f_posts['pcount'];
  1375.         
  1376.         $this->forum['topics'] = $f_topics['tcount'];
  1377.         $this->forum['posts']  = $f_posts['pcount'] - $f_topics['tcount'];
  1378.         
  1379.         $DB->query("SELECT tid, title, last_poster_id, last_poster_name, last_post FROM ibf_topics WHERE approved=1 and forum_id='".$this->forum['id']."' ORDER BY last_post DESC LIMIT 0,1");
  1380.         $last_post = $DB->fetch_row();
  1381.         
  1382.         // Reset this forums stats
  1383.         
  1384.         $db_string = $DB->compile_db_update_string( array (
  1385.                                                              'last_poster_id'   => $last_post['last_poster_id'],
  1386.                                                              'last_poster_name' => $last_post['last_poster_name'],
  1387.                                                              'last_post'        => $last_post['last_post'],
  1388.                                                              'last_title'       => $last_post['title'],
  1389.                                                              'last_id'          => $last_post['tid'],
  1390.                                                              'topics'           => $this->forum['topics'],
  1391.                                                              'posts'            => $this->forum['posts']
  1392.                                                  )        );
  1393.         
  1394.         $DB->query("UPDATE ibf_forums SET $db_string WHERE id='".$this->forum['id']."'");
  1395.         
  1396.         // Update the main board stats.
  1397.         
  1398.         $DB->query("UPDATE ibf_stats SET TOTAL_TOPICS='".$topics['tcount']."', TOTAL_REPLIES='".$posts['pcount']."'");
  1399.         
  1400.     }
  1401.     
  1402.     
  1403.     
  1404.         
  1405.     /*************************************************/
  1406.     
  1407.     function mod_error($error)
  1408.     {
  1409.         global $std, $ibforums, $DB, $print;
  1410.         
  1411.         $error = $ibforums->lang[$error];
  1412.     
  1413.         $this->output .= $this->html->mod_error($error);
  1414.     }
  1415.     
  1416.     function parse_member($member=array()) {
  1417.         global $ibforums, $std, $DB;
  1418.         
  1419.         $member['name'] = "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$member['id']}'>{$member['name']}</a>";
  1420.     
  1421.         $member['avatar'] = $std->get_avatar( $member['avatar'], $ibforums->member['view_avs'], $member['avatar_size'] );
  1422.         
  1423.         $member['MEMBER_JOINED'] = $ibforums->lang['m_joined'].' '.$std->get_date( $member['joined'], 'JOINED' );
  1424.         
  1425.         $member['MEMBER_GROUP'] = $ibforums->lang['m_group'].' '.$member['g_title'];
  1426.         
  1427.         $member['MEMBER_POSTS'] = $ibforums->lang['m_posts'].' '.$member['member_posts'];
  1428.         
  1429.         $member['PROFILE_ICON'] = "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$member['id']}'>{$ibforums->skin['P_PROFILE']}</a> ";
  1430.         
  1431.         $member['MESSAGE_ICON'] = "<a href='{$this->base_url}&act=Msg&CODE=04&MID={$member['id']}'>{$ibforums->skin['P_MSG']}</a> ";
  1432.         
  1433.         if (!$member['hide_email']) {
  1434.             $member['EMAIL_ICON'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->skin['P_EMAIL']}</a> ";
  1435.         }
  1436.         
  1437.         if ( $member['website'] and $member['website'] = preg_match( "/^http:\/\/\S+$/", $member['WEBSITE'] ) ) {
  1438.             $member['WEBSITE_ICON'] = "<a href='{$member['website']}' target='_blank'>{$ibforums->skin['P_WEBSITE']}</a> ";
  1439.         }
  1440.         
  1441.         if ($member['icq_number']) {
  1442.             $member['ICQ_ICON'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_ICQ]}</a> ";
  1443.         }
  1444.         
  1445.         if ($member['aim_name']) {
  1446.             $member['AOL_ICON'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_AOL]}</a> ";
  1447.         }
  1448.         
  1449.         //-----------------------------------------------------
  1450.         
  1451.         return $member;
  1452.     
  1453.     }
  1454.  
  1455.     
  1456. }
  1457.  
  1458. ?>
  1459.